#include "ScnsW25qxx.c.h"

#if defined(SCNS_W25QXX_ENABLE)&&SCNS_W25QXX_ENABLE==1

#include "ScnsTimer.h"

const ScnsBspW25qxxConfig scnsBspW25qxxConfig[SCNS_W25QXX_MAX]={
    {.isQspi=0,},
};

ScnsStatus scnsBspW25qxxInit(ScnsW25qxxEnum icmN)
{
    spi_init(SPI_2,SPI_MODE3,1000*1000,SPI2_SCK_B13,SPI2_MOSI_B15,SPI2_MISO_B14,SPI_CS_NULL);
    gpio_init(B12,GPO,1,GPO_PUSH_PULL);
    scnsDelayMs(1000);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspW25qxxSpiW(ScnsW25qxxEnum w25N,const uint8*val,uint32 num)
{
    spi_write_8bit_array(SPI_2,val,num);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspW25qxxSpiWR(ScnsW25qxxEnum w25N,const uint8*val,uint32 num,uint8*val2,uint32 num2)
{
    spi_write_8bit_array(SPI_2,val,num);
    spi_read_8bit_array(SPI_2,val2,num2);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspW25qxxSpiWW(ScnsW25qxxEnum w25N,const uint8*val,uint32 num,const uint8*val2,uint32 num2)
{
    spi_write_8bit_array(SPI_2,val,num);
    spi_write_8bit_array(SPI_2,val2,num2);
    return SCNS_STATUS_OK;
}

void scnsBspW25qxxSpiSetCs(ScnsW25qxxEnum w25N,uint8 dat)
{
    gpio_set_level(B12,dat);
}

#endif
